<template>
  <div :class="listClass" :style="listStyle">
      <div :class="headerClass" v-if="header || $slots.header">
        <slot name="header">{{ header }}</slot>
      </div>
      <ul :class="ulClass">
        <slot></slot>
      </ul>
      <div :class="footerClass" v-if="footer || $slots.footer">
        <slot name="footer">{{ footer }}</slot>
      </div>
  </div>
</template>
<script>
import { oneOf } from "utils/index";
const prefixCls = "vbestui-list";
export default {
  name: "BList",
  provide() {
    return {
      vbestList: this,
    };
  },
  props: {
    header: {
      type: String,
      default: "",
    },
    footer: {
      type: String,
      default: "",
    },
    itemLayout: {
      validator(value) {
        return oneOf(value, ["horizontal", "vertical"]);
      },
      default: "vertical",
    },
    /**隔行变色 */
    stripe: {
      type: Boolean,
      default: false,
    },
    stripeBackgroundColor: {
      type: String,
      default: "",
    },
    showBorder: {
      type: Boolean,
      default: false,
    },
    /**是否显示分割线 */
    split: {
      type: Boolean,
      default: false,
    },
    /**分割线颜色 */
    splitColor: {
      type: String,
      default: "",
    },
    /**list边框颜色 */
    borderColor: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      prefixCls: prefixCls,
    };
  },
  computed: {
    listClass() {
      return [
        `${this.prefixCls}`,
        this.showBorder ? `${this.prefixCls + "-isborder"}` : "",
      ];
    },
    listStyle() {
      return {
        borderColor: this.borderColor,
      };
    },
    ulClass() {
      return [
        `${this.prefixCls + "-ul"}`,
        this.itemLayout == "horizontal"
          ? `${this.prefixCls + "-ul-horizontal"}`
          : "",
      ];
    },
    headerClass() {
      return [`${this.prefixCls + "-header"}`];
    },
    footerClass() {
      return [`${this.prefixCls + "-footer"}`];
    },
  },
};
</script>